package cn.zptc.springbootdemo.web;

import cn.zptc.springbootdemo.domain.Discuss;
import cn.zptc.springbootdemo.service.DiscussService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author ：zhaoweiwei
 * @date ：创建于 2025/4/3 13:45
 * @description：
 * @modified By：
 * @version: 1.0.0
 */
@Controller
@RequestMapping("/discuss")
public class DiscussController {

    @Autowired
    private DiscussService discussService;

    @ResponseBody
    @GetMapping("/add")
    public String add(Discuss discuss){
        Discuss discuss1 = discussService.add(discuss);
        return discuss1.toString();
    }

    @ResponseBody
    @GetMapping("/update")
    public String update(Discuss discuss){
        int i = discussService.update(discuss);
        if (i==1) {
            return "gengxin chenggong!";
        }else {
            return "gengxin shibai";
        }
    }
    @ResponseBody
    @GetMapping("/delete")
    public String delete(Integer id){
        int i = discussService.delete(id);
        if (i==1) {
            return "shangchu chenggong!";
        }else {
            return "shanchu shibai";
        }
    }
}
